
//
//  UIBarButtonItem+Extension.swift
//  weibo
//
//  Created by libowen on 16/5/20.
//  Copyright © 2016年 libowen. All rights reserved.
//

import Foundation
import UIKit
extension UIBarButtonItem {
    convenience init(imageName: String? = nil,title: String? = nil,target: AnyObject?,action: Selector) {
        self.init()
        let btn = UIButton()
        
        if let img = imageName {
            
            btn.setImage(UIImage(named: img), forState: .Normal)
            
            btn.setImage(UIImage(named: img + "_highlight"), forState: .Highlighted)
        }
        btn.addTarget(target, action: action, forControlEvents: .TouchUpInside)
        
        btn.setTitle(title, forState: .Normal)
        btn.setTitleColor(UIColor.darkGrayColor(), forState: .Normal)
        btn.setTitleColor(UIColor.orangeColor(), forState: .Highlighted)
        btn.sizeToFit()
        self.customView = btn
    }
}





















